<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
    <script type="text/javascript" src="../../src/objx.test.js"></script>
    <script type="text/javascript" src="../../src/objx.js"></script>
    <script type="text/javascript">
    
        function test_mixins()
        {
            
            var mixin = {
                method1: function(){ return 1; },
                method2: function(){ return 2; },
                method3: function(){ return 3; }
            }
            
            var MyClass = Class(mixin, {
                method4: function(){
                    return this.method1();
                }
            });
            
            var myInst = new MyClass();
            
            assertNotUndefined("myInst.method1", myInst.method1);
            assertNotUndefined("myInst.method2", myInst.method2);
            assertNotUndefined("myInst.method3", myInst.method3);
            assertNotUndefined("myInst.method4", myInst.method4);
            
            assertEquals(1, myInst.method1());
            assertEquals(2, myInst.method2());
            assertEquals(3, myInst.method3());
            assertEquals(1, myInst.method4());
            
        }
        
        function test_mixinsContributeTowardsSatisfyingInterfaces()
        {
        
            var mixin = {
                methodInMixin: function(oneArg){ return oneArg; }
            };
            
            var myInterface = Interface({
                methodInMixin: Method("oneArg"),
                methodInClassDefinition: Method(0)
            });
       
            var myClass = null;
            
            assertNotThrows("The mixin did not contribute towards the interface and it should have.", function(){
       
                myClass = Class(mixin, myInterface, {
                    methodInClassDefinition: function(){ return this.methodInMixin(2); }
                });
                
            });
        
        }
        
    </script>
</head>
<body>
</body>
</html>